package com.bkgy.modular.tpdodata_cal1630.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bkgy.controller.technology.entity.AnnealingBase;
import com.bkgy.modular.tpdodata_cal1630.entity.TPdoDataCal1630;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface TPdoDataCal1630Mapper extends BaseMapper<TPdoDataCal1630> {
    List<AnnealingBase> select1630Base(String beginDate);

    @Select("SELECT t1.entid, t1.extid, t1.OUT_MAT_ACT_LEN " +
            "FROM t_pdo_data_l3_cal1630 t1 " +
            "JOIN ( " +
            "    SELECT entid " +
            "    FROM t_pdo_data_l3_cal1630 " +
            "    WHERE final_coil_flag = 1 AND norm = 0 and curve_flag = 1 " +
            "    AND PROD_END_TIME <= #{nowFormat} " +
            "    ORDER BY PROD_END_TIME DESC " +
            "    FETCH FIRST 20 ROWS ONLY " +
            ") t2 ON t1.entid = t2.entid " +
            "ORDER BY t1.PROD_END_TIME DESC")
    List<TPdoDataCal1630> selectWithSubQuery(@Param("nowFormat") String nowFormat);
}




